<template>
  <header class="header">
    <h1>小黑记事本</h1>
    <input placeholder="请输入任务" class="new-todo" v-model="todoVal" />
    <button class="add" @click="add">添加任务</button>
  </header>
</template>

<script>
export default {
  data() {
    return {
      todoVal: "",
    };
  },
  methods: {
    add() {
      if (this.todoVal === "") {
        return;
      }
      this.$emit("addList", this.todoVal);
      this.todoVal = "";
    },
  },
};
</script>

<style>
</style>